/**
 * 게시판 제어용 스크립트 작성일 : 2014.11.10 작성자 : 신재업
 */

function general() {
	var f = document.listfrm;
	
	if (document.getElementById("btninput") != null) {
		document.getElementById("btninput").onclick = function() {
			f.action = "board_main.jsp?inpage=../mboard/mboard_input.jsp";
			f.submit();
		}
	}
	if (document.getElementById("btnlist") != null) {
		document.getElementById("btnlist").onclick = function() {
			f.action = "board_main.jsp?inpage=../mboard/mboard_list.jsp";
			f.submit();
		}
	}

}

function inputinit() {
	general();
	var f = document.mboardfrmin;
	if (document.getElementById("btnsave") != null) {
		document.getElementById("btnsave").onclick = function() {
			f.submit();
		}
	}
	if (document.getElementById("btnresave") != null) {
		document.getElementById("btnresave").onclick = function() {
			f.submit();
		}
	}
	if (document.getElementById("btncan") != null) {
		document.getElementById("btncan").onclick = function() {
			var fl = document.listfrm;
			var rno = fl.rno.value;
			if(rno==0){
				fl.action="board_main.jsp?inpage=../mboard/mboard_list.jsp"
				fl.submit();
			}else{
				fl.action="board_main.jsp?inpage=../mboard/mboard_view.jsp"
				fl.submit();
			}
		}
	}
}

function listinit() {
	general();
	var f = document.searchfrm;
	if (document.getElementById("findgo") != null) {
		document.getElementById("findgo").onclick = function() {
			f.submit();
		}
	}
	if (document.getElementById("mainlist") != null) {
		document.getElementById("mainlist").onclick = function() {
			location.href="board_main.jsp?inpage=../mboard/mboard_list.jsp"
		}
	}

}
function viewinit() {
	general();
	if(document.getElementById("btndel")!=null){
	document.getElementById("btndel").onclick = function() {
		var f = document.viewfrm;
		var b = confirm("삭제?");
		if (b) {
			f.action = "board_main.jsp?inpage=../mboard/mboard_delete.jsp"
			f.submit();
		}
	}
	}
	if(document.getElementById("btnmodi")!=null){
	document.getElementById("btnmodi").onclick = function() {
		var f = document.viewfrm;
		f.action = "board_main.jsp?inpage=../mboard/mboard_modi.jsp"
		f.submit();

	}
	}
	if(document.getElementById("btninputre")!=null){
	document.getElementById("btninputre").onclick = function() {
		var f = document.viewfrm;
		f.action = "board_main.jsp?inpage=../mboard/mboard_reinput.jsp"
		f.submit();
	}
	}

}
function deletinit() {
	general();
}
function modiinit() {
	general();
	var f = document.mboardfrm;
	if (document.getElementById("btnsave") != null) {
		document.getElementById("btnsave").onclick = function() {
			f.submit();
		}
	}
	if (document.getElementById("btncan") != null) {
		document.getElementById("btncan").onclick = function() {
			var rno=document.getElementById("rno").value; 
			location.href="board_main.jsp?inpage=../mboard/mboard_view.jsp&rno="+rno;
		}
	}

}

function goView(rno) {
	var f = document.listfrm;
	f.action = "board_main.jsp?inpage=../mboard/mboard_view.jsp";
	f.rno.value = rno;
	f.submit();
}
function goPage(nowpage){
	var f = document.listfrm;
	f.action = "board_main.jsp?inpage=../mboard/mboard_list.jsp";
	f.nowpage.value = nowpage;
	f.submit();
	
}
